<?php
declare (strict_types = 1);
namespace adminmatrix\server\app\lists;

trait ListsSearchTrait
{
    protected array $withSearch;     # 要搜索的数据
    protected array $with;           # 要搜索的字段
    protected bool $isSearch = true;
    public function initSearch()
    {
        if(isset($this->withSearch)) {

            $this->with     = $this->withSearch;
            $this->withSearch     = $this->request->only($this->with);
            $parentClass = @class_parents($this->model);
            if (isset($parentClass['adminmatrix\server\app\model\BaseModel']) && $this->isSearch)
            {
                $this->model->withSearch($this->with, $this->withSearch);
            }
        }


    }
}